package com.xiaoq.matrix.activity.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.xiaoq.matrix.activity.entity.ActivityAttendentEntity;
import com.xiaoq.matrix.activity.repository.IActivityAttendRepository;
import com.xiaoq.matrix.activity.service.IActivityAttendService;
import com.xiaoq.vo.PagingVo;

@Component
public class ActivityAttendServiceImpl implements IActivityAttendService {
	
	@Autowired
	private IActivityAttendRepository acitivityAttendRep;

	@Override
	public List<ActivityAttendentEntity> findActivityAttendByAct(String activityId) {
		
		return acitivityAttendRep.findActivityAttendByAct(activityId);
	}

	@Override
	public boolean addActivityAttend(ActivityAttendentEntity activityAttend) {
		
		return acitivityAttendRep.addActivityAttend(activityAttend);
	}

	@Override
	public List<ActivityAttendentEntity> findActivityAttendByUser(String userId, PagingVo pvo) {
		
		return acitivityAttendRep.findActivityAttendByUser(userId, pvo);
	}

	@Override
	public Long getAttendNums(String activityId) {
		
		List<ActivityAttendentEntity> activityAttendList = acitivityAttendRep.findActivityAttendByAct(activityId);
		Long attendNums = 0L;
		if(activityAttendList!=null){
			for(ActivityAttendentEntity activityAttend:activityAttendList){
				attendNums = attendNums+activityAttend.getUserCount();
			}
		}
		return attendNums;
	}

	@Override
	public boolean isUserAttend(String userId, String activityId) {
		
		return acitivityAttendRep.isUserAttend(userId, activityId);
	}
	
	

	
}
